package alg20250206;

public class Text2 {

    public void duplicateZeros(int[] arr) {
        int n = arr.length;
        int cur = 0, dest = -1;
        while(cur < n){
            if(dest >= n - 1) break;
        }
        if(dest == n){
            arr[n - 1] = 0;
            dest -= 2;
            cur--;
        }
        while(cur > 0){
            if(arr[cur] == 0){
                arr[dest--] = 0;
                arr[dest--] = 0;
                cur--;
            }else{
                arr[dest--] = arr[cur--];
            }
        }
    }


}
